package com.tdkj.action.backstage.website;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import com.tdkj.action.BaseAction;
import com.tdkj.model.website.BeanKeywordsFilter;
import com.tdkj.service.website.IBeanKeywordsFilterService;
public class KeywordsFilterAction  extends BaseAction{
	private IBeanKeywordsFilterService keywordsFilterService;
	private long id;
	private String word;
	private Timestamp createtime;
	private List<BeanKeywordsFilter> keywords=new ArrayList<BeanKeywordsFilter>();
	public IBeanKeywordsFilterService getKeywordsFilterService() {
		return keywordsFilterService;
	}
	@Resource
	public void setKeywordsFilterService(
			IBeanKeywordsFilterService keywordsFilterService) {
		this.keywordsFilterService = keywordsFilterService;
	}
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public String getWord() {
		return word;
	}
	public void setWord(String word) {
		this.word = word;
	}
	public Timestamp getCreatetime() {
		return createtime;
	}
	public void setCreatetime(Timestamp createtime) {
		this.createtime = createtime;
	}
	public List<BeanKeywordsFilter> getKeywords() {
		return keywords;
	}
	public void setKeywords(List<BeanKeywordsFilter> keywords) {
		this.keywords = keywords;
	}
	
	//后去qq列表
	public String findAll(){
		keywords=keywordsFilterService.findAll(BeanKeywordsFilter.class);
		return "findAll";
	}
	//获取添加界面
	public String getEditPage(){
		BeanKeywordsFilter bean=new BeanKeywordsFilter();
		bean=keywordsFilterService.findById(this.getId(), BeanKeywordsFilter.class);
		this.setId(bean.getId());
		this.setCreatetime(bean.getCreatetime());
		this.setWord(bean.getWord());
		return "editPage";
	}
	//获取添加界面
	public String getAddPage(){
		return "addPage";
	}
	//删除QQ
	public String deleteKeywords(){
		long id=this.getId();
		BeanKeywordsFilter bean=new BeanKeywordsFilter();
		bean.setId(id);
		keywordsFilterService.delete(bean);
		return findAll();
	}
	//获取添加界面
	public String addKeywords(){
		BeanKeywordsFilter bean=new BeanKeywordsFilter();
		bean.setCreatetime(new Timestamp(System.currentTimeMillis()));
		bean.setWord(this.getWord());
		keywordsFilterService.save(bean);
		return findAll();
	}
	//获取添加界面
	public String editKeywords(){
		BeanKeywordsFilter bean=new BeanKeywordsFilter();
		bean.setCreatetime(new Timestamp(System.currentTimeMillis()));
		bean.setId(this.getId());
		bean.setWord(this.getWord());
		keywordsFilterService.merge(bean);
		return findAll();
	}
	
}
